import logging
import logging.handlers


class Logger(object):

    def __init__(self, file_path, log_name):
        self.file_handler = logging.handlers.TimedRotatingFileHandler(file_path, 'D', 1, 30)
        self.file_handler.suffix = "%Y%m%d-%H%M.log"

        self.stream_handler = logging.StreamHandler()

        self.formatter = logging.Formatter('%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s - %(message)s')

        self.logger = logging.getLogger(log_name)

        self.file_handler.setFormatter(self.formatter)
        self.stream_handler.setFormatter(self.formatter)

        self.file_handler.setLevel(logging.INFO)
        self.stream_handler.setLevel(logging.DEBUG)

        self.logger.addHandler(self.file_handler)
        self.logger.addHandler(self.stream_handler)

        self.logger.setLevel(logging.DEBUG)